
//引入网络库
import { get, post } from "../../util/util.js"

// 获取全局应用程序实例对象
var app = getApp();

// 创建页面实例对象
Page({
  /**
   * 页面名称 
   */
  name: "searchresult",
  /**
   * 页面的初始数据 
   */

  data: {
    uid: "",
    param: {},
    //上下拉
    newlist: {},
    pagesize: 1,
    loading: false,
    defaulImg: "http://wolaimage-10029986.image.myqcloud.com/1-2016051421050035278.png"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    wx.getStorage({
      key: 'login',
      success: function (res) {
        var data = res.data
        that.setData({
          uid: data.data.uid
        });
      },
    })
  },

  onLoad: function (o) {
    var that = this
    var param = {};
    console.log("搜索结果====" + JSON.stringify(o.param));
    that.setData({
      param: JSON.parse(o.param)
    })

    post("/com/searchActor", JSON.parse(o.param)).then(data => {
      console.log('com/searchActor====================' + JSON.stringify(data.data));
      if (data.code == 0) {
        that.setData({
          pagesize: 1,
          newlist: data.data
        })
      }
    })
  },
  onReachBottom: function () {
    var that = this;
    var data = {};
    data = that.data.param;
    that.setData({
      page: ++that.data.pagesize,
      loading: true,
    })
    data.page = that.data.pagesize;
    data.pagesize = 2;
    that.setData({
      param: data
    })

    // post("/actor/baselist", { page: that.data.pagesize, pagesize: 2 }).then(data => {
    post("/com/searchActor", that.data.param).then(data => {
      console.log('首页艺人数据获取====================' + JSON.stringify(data.data));
      that.setData({
        loading: false,
        newlist: that.data.newlist.concat(data.data)
      })
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    console.log('下拉刷新====================');
    this.onLoad()
    wx.stopPullDownRefresh()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },


  //以下为自定义点击事件

})

